#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2025/10/29 19:18
# @Author  : summer
# @Email   : 610658552@qq.com
# @File    : filter_sms_template.py
# @Software: PyCharm
# @Desc    :
import django_filters
from ssms.models import SMSLog


class SMSLogFilter(django_filters.FilterSet):
    """SMSTemplate过滤器：支持多条件筛选"""
    # 按名称模糊搜索
    phone = django_filters.CharFilter(field_name='phone', lookup_expr='icontains')
    # sign筛选
    sign = django_filters.NumberFilter(field_name='sign')
    # 按模板template_id精确匹配
    template_id = django_filters.CharFilter(field_name='template_id', lookup_expr='exact')
    content = django_filters.CharFilter(field_name='content', lookup_expr='icontains')
    # 按创建时间范围筛选
    create_time_start = django_filters.DateTimeFilter(field_name='create_time', lookup_expr='gte')
    create_time_end = django_filters.DateTimeFilter(field_name='create_time', lookup_expr='lte')

    class Meta:
        model = SMSLog
        fields = "__all__"